package com.example.myapplication.tack_22;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.example.myapplication.R;
import com.example.myapplication.tack_22.data.OverviewData;
import com.example.myapplication.utils.OkHttpTool;

public class OverviewMapActivity extends AppCompatActivity {
    private ImageView exit;
    private ImageView img;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tack_22_activity_overview_map);
        init();
        exit_();
        getImg();
    }

    private void getImg() {
        String url = "prod-api/api/metro/city";
        OkHttpTool.doNetRequest(url, OkHttpTool.GET, OverviewData.class, new OkHttpTool.NetCallback() {
            @Override
            public void onSuccess(Object obj) {
                OverviewData value = (OverviewData)obj;
                if(value.getCode() == 200){
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            Glide.with(OverviewMapActivity.this).load(OkHttpTool.URL + value.getData().getImgUrl()).into(img);
                        }
                    });
                }
            }

            @Override
            public void onFailure(String msg) {

            }
        });
    }

    private void exit_() {
        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                OverviewMapActivity.this.finish();
            }
        });
    }

    private void init() {
        exit = findViewById(R.id.exit);
        img = findViewById(R.id.img);
    }
}